<template>
	<view class="content">
		<scroll-view scroll-x="true">
			<view class="topSearch">
				<uamhead :title="title"></uamhead>
				<view @click="Tosearch">
					<image class="search" src="../../static/images/search.png"></image>
				</view>
			</view>
			<scroll-view scroll-y="true">
				<view>
					<m-for-skeleton :avatarSize="200" :row="3" :title="false" :loading="loading" isarc="square"
						:titleStyle="{}" v-for="(item,key) in 4" :key="key">
					</m-for-skeleton>

					<view class="index-list" v-for="(item,index) in playList" :key="index + 4"
						@click="handleToList(item.id)">
						<view class="index-list-item">
							<view class="text">
								<image :src="item.coverImgUrl">
									<view class="SongTime">{{item.updateFrequency}}</view>
								</image>
							</view>

							<view class="index-lis-song">
								<view class="text2" v-for="(song,index) in item.tracks" :key="index">
									{{index+1}}.{{song.first}} - {{song.second}}
								</view>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</scroll-view>

	</view>
</template>

<script>
	import {
		topList
	} from "../../common/api.js"
	// const potlistdata = require('@/static/toplist.json')
	import mForSkeleton from "@/components/m-for-skeleton/m-for-skeleton";
	import search from '../../components/common/search.vue'
	export default {
		data() {
			return {
				playList: [],
				title: 'MAMusic',
				loading: true
			}
		},
		components: {
			mForSkeleton,
			search
		},
		onLoad() {
			// this.playList = potlistdata;
			// console.log(this.playList)

			topList().then((res) => {
				console.log(res)
				if (res.length) {
					setTimeout(() => {
						this.playList = res;
						this.loading = false;
					}, 2000);
				}
			})
		},
		methods: {
			handleToList(id) {
				// uni.switchTab 无法传参
				console.log('dd')
				uni.navigateTo({
					url: '/components/index/list?listid=' + id
				})
			},
			hide() {
				this.loading = false;
			},
			Tosearch() {
				uni.navigateTo({
					url: '/components/common/search'
				})
			}

		}
	}
</script>

<style>
	.content .text-area {
		display: flex;
		justify-content: center;
	}

	.text-area .title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.index-list {
		margin: 0 30rpx;
	}

	.index-list-item {
		margin-top: 20rpx;
		display: flex;

	}

	.index-list image {
		width: 250rpx;
		height: 250rpx;
		border-radius: 10rpx;
	}

	.index-list-item .text2 {
		line-height: 40rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		margin: 20rpx 40rpx;
		font-size: 26rpx;
		color: #4c4c4c;

	}

	.index-list-item .SongTime {
		position: relative;
		/* 		    top: -38px;
		    left: 46px; */
		top: -88rpx;
		left: 60rpx;
		font-size: 28rpx;
		color: #dedede;
	}

	.topSearch {
		display: flex;
		position: relative
	}

	.topSearch .search {
		width: 50rpx;
		height: 50rpx;
		position: absolute;
		right: 20rpx;
		margin-top: 50rpx;
	}
</style>
